package com.hdd.biz.huodong.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hdd.biz.huodong.entity.ActivityPrize;
import com.hdd.biz.huodong.mapper.ActivityPrizeMapper;
import com.hdd.biz.huodong.service.ActivityPrizeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fang
 * @since 2021-07-29
 */
@Service
public class ActivityPrizeServiceImpl extends ServiceImpl<ActivityPrizeMapper, ActivityPrize> implements ActivityPrizeService {

    @Override
    public List<ActivityPrize> prize(Integer activityId) {
        QueryWrapper<ActivityPrize> queryWrapper = new QueryWrapper();
        queryWrapper.eq("activity_id",activityId);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public void add(ActivityPrize activityPrize) {
        baseMapper.insert(activityPrize);
    }


    @Override
    public void delByActivityId(Integer activityId) {
        QueryWrapper<ActivityPrize> queryWrapper = new QueryWrapper();
        queryWrapper.eq("activity_id",activityId);
        baseMapper.delete(queryWrapper);
    }

    @Override
    public void del(Integer id, Integer activityId) {
        QueryWrapper<ActivityPrize> queryWrapper = new QueryWrapper();
        queryWrapper.eq("activity_id",activityId);
        queryWrapper.eq("id",id);
        baseMapper.delete(queryWrapper);
    }

    @Override
    public Integer prizes(Integer activityId) {
        QueryWrapper<ActivityPrize> queryWrapper = new QueryWrapper();
        queryWrapper.eq("activity_id",activityId);
        return baseMapper.selectCount(queryWrapper);
    }


}
